package com.moter.one.wyydemo1.controller;

import com.moter.one.wyydemo1.entity.SongInfo;
import com.moter.one.wyydemo1.entity.UserInfo;
import com.moter.one.wyydemo1.service.SongInfoService;
import org.apache.catalina.LifecycleState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
//热歌//根据播放量选择Top8的歌曲
public class HotRecommend {
    @Autowired
    SongInfoService songInfoService;
    @RequestMapping("/HotRecommend")
    public List<SongInfo> getTop8Songs(String type){//从数据库中选出type类型的播放量前8的歌曲
        //对应接口axios.get的url传值
        List<SongInfo> list = null;
        if(type == null){
//            System.out.println(type);
            list = songInfoService.selectSongInfoTop8Mapper();
//            System.out.println(list);
        }else {
            list = songInfoService.selectSongInfoTop8Mapper(type);//返回type类型播放量前8的歌曲所有信息
//            System.out.println(list);
        }
        return list;
    }
}
